package com.lg.concurrent.pool.thread_pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * newCachedThreadPool
 *
 * ThreadPoolExecutor(0, Integer.MAX_VALUE,
 *                                       60L, TimeUnit.SECONDS,
 *                                       new SynchronousQueue<Runnable>());
 *newCachedThreadPool（）
 *  corePoolSize：0
 *  maximumPoolSize： integer.masx
 *  keepAliveTime ：60
 *  TimeUnit：s
 *  workQueue： SynchronousQueue
 *
 *   初始线程为0，来一个任务就创建一个线程，新创建的线程休息60s后死亡，又名在缓存中的线程池
 *
 */
public class CachedThreadPoolTest {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        Task task = new Task();
        Task task2 = new Task();
        executorService.execute(task);
        executorService.execute(task2);
    }
}
